<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'tutor-form',
	'enableAjaxValidation'=>false,
        'htmlOptions'=>array('enctype'=>'multipart/form-data')
)); ?>

	<p class="note">Những ô <span class="required">*</span> cần phải nhập.</p>

	<?php echo $form->errorSummary($model); ?>

        <fieldset class="classFieldSet">
            <legend>Thông tin gia sư</legend>
            <table>
                <tr>
                    <td class="titleInput"><?php echo $form->labelEx($model,'tutor_name'); ?></td>
                    <td class="dataInput">
                        <?php echo $form->textField($model,'tutor_name',array('size'=>60,'maxlength'=>200)); ?>
                        <?php echo $form->error($model,'tutor_name'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="titleInput"><?php echo $form->labelEx($model,'image_path'); ?></td>
                    <td class="dataInput">
                        <?php echo CHtml::activeFileField($model, 'image');  ?>
                    </td>
                </tr>
                <tr>
                    <td class="titleInput">Địa chỉ</td>
                    <td class="dataInput">
                        <?php echo $form->textField($model,'home_number',array('size'=>10,'maxlength'=>10)); ?>
                        <?php echo $form->textField($model,'street',array('size'=>30,'maxlength'=>250)); ?>
                        <?php echo $form->dropDownList($model,'id_district',CHtml::listData(District::model()->findAll(array('order'=>'id')),'id','name'),array());?>
                    </td>
                </tr>
                <tr>
                    <td class="titleInput"><?php echo $form->labelEx($model,'birthday'); ?></td>
                    <td class="dataInput">
                        <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                            'name'=>'Tutor[birthday]',
                            'attribute'=>'birthday',
                            'model'=>$model,
                            // additional javascript options for the date picker plugin
                            'options'=>array(
                                'showAnim'=>'fold',
                                'dateFormat'=>'yy-mm-dd',

                            ),
                            'htmlOptions'=>array(
                                'style'=>'height:20px;'
                            ),
                        ));
                        ?>
                    <?php echo $form->error($model,'birthday'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="titleInput"><?php echo $form->labelEx($model,'sex'); ?></td>
                    <td class="dataInput">
                        <?php echo $form->radioButtonList($model,'sex',array('1'=>'Nam','0'=>'Nu'),array('separator'=>''));?>
                    <?php echo $form->error($model,'sex'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="titleInput"><?php echo $form->labelEx($model,'phone'); ?></td>
                    <td class="dataInput">
                        <?php echo $form->textField($model,'phone',array('size'=>20,'maxlength'=>20)); ?>
                        <?php echo $form->error($model,'phone'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="titleInput"><?php echo $form->labelEx($model,'email'); ?></td>
                    <td class="dataInput">
                        <?php echo $form->textField($model,'email',array('size'=>50,'maxlength'=>50)); ?>
                        <?php echo $form->error($model,'email'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="titleInput"><?php echo $form->labelEx($model,'is_teacher'); ?></td>
                    <td class="dataInput">
                        <?php echo $form->radioButtonList($model,'is_teacher',array('1'=>'Giáo viên','0'=>'Sinh viên'),array('separator'=>''));?>
                        <?php echo $form->error($model,'is_teacher'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="titleInput"><?php echo $form->labelEx($model,'school'); ?></td>
                    <td class="dataInput">
                        <?php echo $form->textField($model,'school',array('size'=>50,'maxlength'=>50)); ?>
                        <?php echo $form->error($model,'school'); ?>
                    </td>
                </tr>
                <tr>
                    <td class="titleInput"><?php echo $form->labelEx($model,'branch'); ?></td>
                    <td class="dataInput">
                        <?php echo $form->textField($model,'branch',array('size'=>50,'maxlength'=>50)); ?>
                        <?php echo $form->error($model,'branch'); ?>
                    </td>
                </tr>
            </table>
        </fieldset>

        <fieldset class="classFieldSet">
            <legend>Thông tin yêu cầu</legend>
            <table>
                   <tr>
                    <td class="titleInput">
                        <?php echo CHtml::encode("Môn có thể dạy"); ?>
                    </td>
                    <td class="dataInput">
                        <?php
                            $subject_list = Subject::model()->findAll();
                            $subject_num  = count($subject_list);
                            $row_num = $subject_num/4;
                            if(($subject_num%4) != 0) {
                                $row_num+=1;
                            }
                            $pointer = 0;
                        ?>
                         <table>
                            <tr>
                                <?php for ($i=0; $i < 4; $i++) { ?>
                                <td>
                                    <?php
                                        $subject_list = Subject::model()->findAll(array('limit'=>$row_num, 'offset'=>$pointer, 'order'=>'id'));
                                        foreach ($subject_list as $subject) {
                                    ?>
                                        <input type="checkbox" name="Tutor[subjectIds][]" value="<?php echo $subject->id;?>"  <?php
                                        if(in_array($subject->id, $model->subjectIds)) echo "checked";
                                     ?>>
                                    <?php echo $subject->name;?>
                                    <br>
                                    <?php
                                    }?>
                                </td>
                                <?php $pointer+=$row_num;
                                } ?>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td class="titleInput">
                        <?php echo CHtml::encode("Quận có thể dạy"); ?>
                    </td>
                    <td class="dataInput">
                        <?php
                            $district_list = District::model()->findAll();
                            $district_num  = count($district_list);
                            $row_num = $district_num/4;
                            if(($district_num%4) != 0) {
                                $row_num+=1;
                            }
                            $pointer = 0;
                        ?>
                         <table>
                            <tr>
                                <?php for ($i=0; $i < 4; $i++) { ?>
                                <td>
                                    <?php
                                        $district_list = District::model()->findAll(array('limit'=>$row_num, 'offset'=>$pointer, 'order'=>'id'));
                                        foreach ($district_list as $district) {
                                    ?>
                                        <input type="checkbox" name="Tutor[districtIds][]" value="<?php echo $district->id;?>"  <?php
                                        if(in_array($district->id, $model->districtIds)) echo "checked";
                                     ?>>
                                    <?php echo $district->name;?>
                                    <br>
                                    <?php
                                    }?>
                                </td>
                                <?php $pointer+=$row_num;
                                } ?>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td class="titleInput"><?php echo $form->labelEx($model,'school_fees'); ?></td>
                    <td class="dataInput">
                        <?php echo $form->textField($model,'school_fees',array('size'=>20,'maxlength'=>20)); ?>
                        <?php echo $form->error($model,'school_fees'); ?>
                    </td>
                </tr>

                <tr>
                    <td class="titleInput"><?php echo $form->labelEx($model,'want_teacher_course'); ?></td>
                    <td class="dataInput">
                        <?php echo $form->radioButtonList($model,'want_teacher_course',array('1'=>'Có','0'=>'không'),array('separator'=>''));?>
                        <?php echo $form->error($model,'want_teacher_course'); ?>
                    </td>
                </tr>
                
                <tr>
                    <td class="titleInput"><?php echo $form->labelEx($model,'is_arrange'); ?></td>
                    <td class="dataInput">
                        <?php echo $form->radioButtonList($model,'is_arrange',array('1'=>'Có','0'=>'không'),array('separator'=>''));?>
                        <?php echo $form->error($model,'is_arrange'); ?>
                    </td>
                </tr>

                <tr>
                    <td class="titleInput">
                        Tạo TKB
                    </td>
                    <td class="dataInput">
                        <table>
                            <tr>
                                <td>

                                </td>
                                <td>
                                    T2
                                </td>
                                <td>
                                    T3
                                </td>
                                <td>
                                    T4
                                </td>
                                <td>
                                    T5
                                </td>
                                <td>
                                    T6
                                </td>
                                <td>
                                    T7
                                </td>
                                <td>
                                    CN
                                </td>
                            </tr>
                            <tr>
                                <td>
                                   Sáng
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date1'); ?><br>
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date2'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date3'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date4'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date5'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date6'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date7'); ?><br>
                                    
                                </td>
                            </tr>
                            <tr>
                                <td>
                                   Chiều
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date8'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date9'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date10'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date11'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date12'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date13'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date14'); ?><br>
                                    
                                </td>
                            </tr>
                            <tr>
                                <td>
                                   Tối
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date15'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date16'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date17'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date18'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date19'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date20'); ?><br>
                                    
                                </td>
                                <td>
                                    <?php echo $form->checkBox($model,'date21'); ?><br>
                                    
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td class="titleInput"><?php echo $form->labelEx($model,'other_request'); ?></td>
                    <td class="dataInput">
                        <?php echo $form->textArea($model,'other_request',array('rows'=>6, 'cols'=>50)); ?>
                        <?php echo $form->error($model,'other_request'); ?>
                    </td>
                </tr>
            </table>
        </fieldset>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Tạo' : 'Lưu'); ?>
	</div>

<?php $this->endWidget(); ?>